package com.t360.cubesolver;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;

public class Main {
	public static void main(String[] args) {
		// The name of the file that contains the puzzle can be specified via command line
		// If nothing is specified, the file "defaultCube.txt" will be used
		String puzzleFile = args.length > 0 ? args[0] : "defaultCube.txt";
		
		try {
			// Read the file
			Puzzle pieces = PuzzleReader.fromFile(new File(puzzleFile));
			
			// Create the hash map that will contain the solutions
			HashMap<String, Solution> solutions = new HashMap<String, Solution>();
			
			// Solve the puzzle
			pieces.solve(solutions);
			
			// Print the solutions
			System.out.println(solutions.size() + " solutions have been found\n====");
			for (String solution : solutions.keySet()) {
				System.out.println(solution + "====");
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
